package com.blb.mapper;

import com.blb.entity.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author tb
 * @since 2020-05-20
 */
public interface RoleMapper extends BaseMapper<Role> {
    /**
     * 修改状态
     * @param statues
     * @param id
     */
    void updateStatus (@Param("statues")String statues , @Param("id")String id);

    /**
     * 添加员工
     * @param role
     * @return
     */
    int addRole(Role role);
    /**
     * 模糊查询
     * @param roleName
     * @return
     */
    List<Role> selectRoleByRoleName(String roleName);

    /**
     * 判断角色是否存在
     * @param roleName
     * @param companyId
     * @return
     */
    @Select("select * from t_role where role_name=#{roleName} and company_id=#{companyId}")
    Role roleNameisExist(@Param("roleName")String roleName,@Param("companyId")String companyId);

    /**
     * 根据id查询角色信息
     * @param id
     * @param companyId
     * @return
     */
    @Select("select * from t_role where id=#{id} and company_id=#{companyId}")
    Role selectOneRole(@Param("id")String id,@Param("companyId")String companyId);

    @Select("select * from t_role where company_id=#{companyId} limit #{page},#{limit}")
    List<Role> getPageRole(@Param("page")Integer page,@Param("limit")Integer limit,@Param("companyId")String companyId);
    @Select("select count(*) from t_role where company_id=#{companyId}")
    int getPageRoleCount(@Param("companyId")String comanyId);
}
